<template>
	<view class="page">
		<view class="flex benben-position-layout flex flex-wrap align-center testExamination_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub testExamination_fd0_0'>
				<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  testExamination_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<text class='testExamination_fd0_0_c1'>渠道码</text>
				<view class='flex flex-wrap align-center testExamination_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#1A66FA"></u-loading>
			<view>加载中</view>
		</view>
		
		<template v-else>
			<view class="list">
				<view class="list_item" v-for="(item, index) in list" :key="index">
					<view class="item_top flex align-center">
						<view class="item_top_le">
							<u-lazy-load height="166" border-radius="16" :image="item.url"></u-lazy-load>
						</view>
						<view class="item_top_ri">
							<view class="item_top_ri_1">{{item.channel_name}}</view>
							<view class="item_top_ri_2">2024.10.20由{{item.pName}}创建</view>
							<view class="item_top_ri_3">
								<!-- <text style="margin-right: 48rpx;">
									<text>昨日订单：</text>
									<text style="color: #222;">0</text>
								</text> -->
								<text>
									<text>订单总计：</text>
									<text style="color: #222;">0</text>
								</text>
							</view>
						</view>
					</view>
					<view class="item_bom flex align-center justify-between">
						<!-- <view class="item_bom_1 flex align-center justify-center">订单通知</view> -->
						<view class="item_bom_2 flex align-center justify-center" @tap.stop="savePhoto(item.url)">下载渠道码</view>
					</view>
				</view>
			</view>
			<view class="noData" v-if="list.length == 0 && !isShow">
				<image :src='STATIC_URL+"no.png"'></image>
			</view>
			
			<view class="picker_btn flex align-center justify-between">
				<view class="picker_btn_1 flex align-center justify-center" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/denglu/agreement/agreement?aid=12`">功能介绍</view>
				<view class="picker_btn_2 flex align-center justify-center" @tap.stop="addChannel">新建</view>
			</view>
		</template>
		
		<u-popup v-model="priceShow" mode="center" border-radius="32">
			<view class="deductible_popup">
				<view class="pop_title">创建渠道码</view>
				<view class="input_view flex align-center" style="margin-top: 14rpx;">
					<input v-model="channel_name" style="padding: 0 30rpx 0 16rpx;" class="input" type="text" maxlength="20" placeholder="请输入渠道码名称" placeholder-style="font-size:32rpx;color:#999;">
				</view>
				<view class="operation flex align-center justify-between" style="margin: 94rpx 0 54rpx;">
					<view class="operation_1 flex align-center justify-center" @tap.stop="cancelAdd">取消</view>
					<view class="operation_2 flex align-center justify-center" @tap.stop="confirmAdd">确定</view>
				</view>
				<view class="pop_bg"></view>
			</view>
		</u-popup>
		
	</view>
</template>
<script>
	export default {
		components: {},

		data() {
			return {
				"order_id": "",
				"name": "",
				"isShow": true,
				"list": [],
				"image": "",
				"priceShow": false,
				"channel_name": "",
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			this.getRecord();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			getRecord() {
				this.$api.post(global.apiUrls.postChannelList, {
					order_id: this.order_id
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.list = res.data.data;
					} else {
						this.$message.info(res.data.info);
					}
				})
			},
			// 新建渠道码
			addChannel() {
				this.channel_name = "";
				this.priceShow = true;
			},
			confirmAdd() {
				if (!this.channel_name) {
					this.$message.info('请输入渠道码名称');
					return;
				}
				this.priceShow = false;
				this.$api.post(global.apiUrls.createQrcode, {
					channel_name: this.channel_name,
					store_id: global.userInfo.store_id,
					pid: global.userInfo.id
				}).then(res => {
					this.$message.info(res.data.info);
					if (res.data.code == 1) {
						this.isShow = true;
						this.getRecord();
					}
				})
			},
			cancelAdd() {
				this.priceShow = false;
			},
			// 下载渠道码
			savePhoto(url) {
				if (!url) {
					this.$message.info('未获取到渠道码图片');
					return;
				}
				let _this = this;
				uni.showLoading({
					title: '保存中'
				})
				// 先下载图片
				uni.downloadFile({
					url: url,
					success: (res) => {
						// 获取到图片本地地址后再保存图片到相册（因为此方法不支持远程地址）
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: () => {
								uni.hideLoading();
								uni.showToast({
									title: "保存成功！",
								});
							},
							fail: () => {
								uni.hideLoading();
								uni.showToast({
									title: "保存失败",
								});
							},
						});
					},
					fail: (err) => {
						uni.hideLoading();
						uni.showToast({
							title: "保存失败",
						});
					}
				});
			},
		}
	};
</script>
<style lang="scss" scoped>
	.list {
		padding: 0 24rpx;
		.list_item {
			margin-top: 16rpx;
			background: #fff;
			border-radius: 16rpx;
			padding: 28rpx 22rpx 32rpx 24rpx;
			.item_top {
				.item_top_le {
					width: 166rpx;
					height: 186rpx;
				}
				/deep/.u-lazy-item {
					width: 166rpx !important;
					height: 186rpx !important;
				}
				.item_top_ri {
					width: calc(100% - 208rpx);
					margin-left: 22rpx;
					.item_top_ri_1 {
						font-weight: bold;
						font-size: 36rpx;
						color: #222222;
					}
					.item_top_ri_2 {
						font-weight: 400;
						font-size: 24rpx;
						color: #666666;
						margin-top: 6rpx;
					}
					.item_top_ri_3 {
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						margin-top: 44rpx;
					}
				}
			}
			.item_bom {
				margin-top: 34rpx;
				.item_bom_1 {
					width: 320rpx;
					height: 80rpx;
					background: #FFFFFF;
					border-radius: 16rpx;
					border: 2rpx solid #EEEEEE;
					font-weight: 400;
					font-size: 28rpx;
					color: #222222;
				}
				.item_bom_2 {
					width: 320rpx;
					height: 80rpx;
					background: #FFFFFF;
					border-radius: 16rpx;
					border: 2rpx solid #EEEEEE;
					font-weight: 400;
					font-size: 28rpx;
					color: #1A66FA;
				}
			}
		}
	}
	.picker_btn {
		width: 100%;
		position: fixed;
		bottom: 0;
		z-index: 10;
		background: #fff;
		padding: 14rpx 30rpx 14rpx;
		height: 124rpx;
	}
	.picker_btn_1 {
		width: 236rpx;
		height: 96rpx;
		background: #F6F7FB;
		border-radius: 16rpx;
		font-weight: 500;
		font-size: 30rpx;
		color: #222222;
	}
	.picker_btn_2 {
		width: 436rpx;
		height: 96rpx;
		background: #1A66FA;
		border-radius: 16rpx;
		font-weight: 500;
		font-size: 30rpx;
		color: #fff;
	}
	.deductible_popup {
		width: 626rpx;
		position: relative;
		.pop_title {
			text-align: center;
			font-weight: 800;
			font-size: 36rpx;
			color: #222222;
			padding: 40rpx 0 12rpx;
		}
		.pop_tips {
			padding: 0 38rpx;
			margin-top: 16rpx;
			position: relative;
			z-index: 10;
			.tips_le {
				width: 8rpx;
				height: 8rpx;
				border-radius: 50%;
				background: #1A66FA;
				margin-right: 16rpx;
				transform: translateY(16rpx);
			}
			.tips_ri {
				width: calc(100% - 24rpx);
				font-weight: 400;
				font-size: 28rpx;
				color: #222222;
				line-height: 36rpx;
			}
		}
		.pop_btn {
			width: 548rpx;
			height: 88rpx;
			background: #1A66FA;
			border-radius: 16rpx;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			margin: 66rpx auto 52rpx;
		}
		.pop_bg {
			width: 100%;
			height: 220rpx;
			background: linear-gradient( 180deg, rgba(26,102,250,0.2) 0%, rgba(255,255,255,0) 100%);
			border-radius: 32rpx 32rpx 0px 0px;
			position: absolute;
			top: 0;
			left: 0;
			z-index: -1;
		}
		.title_text {
			padding: 36rpx 40rpx 22rpx;
			font-weight: 500;
			font-size: 30rpx;
			color: #000000;
		}
		.input_view {
			width: 548rpx;
			height: 88rpx;
			border-radius: 16rpx;
			border: 2rpx solid #1A66FA;
			padding: 24rpx 0rpx;
			margin: 0 40rpx;
			.input {
				padding: 0 30rpx;
			}
			.money_icon {
				font-weight: bold;
				font-size: 32rpx;
				color: #1A66FA;
				margin-left: 30rpx;
			}
		}
		.operation {
			margin: 46rpx 0;
			padding: 0 40rpx;
			.operation_1 {
				width: 266rpx;
				height: 88rpx;
				background: #F6F7FB;
				border-radius: 16rpx;
				font-weight: 500;
				font-size: 32rpx;
				color: #222222;
			}
			.operation_2 {
				width: 266rpx;
				height: 88rpx;
				background: #1A66FA;
				border-radius: 16rpx;
				font-weight: 500;
				font-size: 32rpx;
				color: #fff;
			}
		}
		
		.charge_list {
			overflow: hidden;
			padding: 10rpx 40rpx 0;
			position: relative;
			z-index: 10;
			.charge_item {
				float: left;
				width: 174rpx;
				height: 80rpx;
				background: #F6F7FB;
				border-radius: 16rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #222222;
				margin-bottom: 10rpx;
				margin-right: 10rpx;
				image {
					width: 24rpx;
					height: 24rpx;
					margin-right: 4rpx;
				}
			}
			.active_item {
				color: #1A66FA;
				background: #F1F6FF;
				border: 2rpx solid #AAC7FF;
			}
			.charge_item:nth-child(3n+3) {
				margin-right: 0;
			}
		}
	}
	.personalInformation_fd1_0 {
		padding: 28rpx 0;
		border-top: 2rpx solid #eee;
	}
	
	.personalInformation_fd1_0_c0 {
		font-size: 28rpx;
		color: rgba(0,0,0,0.6);
	}
	.personalInformation_fd1_1_c1 {
		font-size: 28rpx;
		font-weight: 400;
		color: #111;
		text-align: right;
	}
	
	
	.feedback_fd4_0 {
		width: 640rpx;
		border-radius: 80rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #fff;
		margin: 0rpx 32rpx 0rpx 32rpx;
		height: 84rpx;
		line-height: 84rpx;
		text-align: center;
		background: #FC5B03;
	}
	
	.feedback_flex_4 {
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		position: fixed;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		display: flex;
		justify-content: center;
		background: #fff;
	}
	
	
	
	
	.testExamination_fd1_0 {
		margin: 0rpx 16rpx 0rpx 0rpx;
		padding: 40rpx 32rpx 24rpx 32rpx;
	}

	.testExamination_fd1_0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #333333;
	}

	.testExamination_notAnfd1_1_c0 {
		background: rgba(244, 250, 255, 1);
		background-size: 100% !important;
		width: 750rpx;
		height: 80rpx;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.testExamination_anfd1_1_c0 {
		background: rgba(244, 250, 255, 1);
		background-size: 100% !important;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
		width: 750rpx;
		height: 80rpx;
	}

	.testExamination_areafd1_1_c0 {
		min-height: 80rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.testExamination_notAnfd1_1_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_notAnfd1_1_c0_c0_c1 {
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #1593FF;
	}

	.testExamination_notAnfd1_1_c0_c0_c2 {
		font-weight: 700;
		font-size: 32rpx;
		color: #1593FF;
		line-height: 45rpx;
		text-decoration: none;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.testExamination_anfd1_1_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.testExamination_anfd1_1_c0_c0_c1 {
		margin: 0rpx 20rpx 0rpx 0rpx;
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 700;
		color: #1593FF;
	}

	.testExamination_anfd1_1_c0_c0_c2 {
		font-weight: 700;
		font-size: 32rpx;
		color: #1593FF;
		line-height: 45rpx;
		text-decoration: none;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.testExamination_areafd1_1_c0_c0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 40rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 15rpx 0rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c0_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c0 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(21, 147, 255, 1);
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c1 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c3 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 32rpx 0rpx 0rpx;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c4 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c0_c1_c5 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
	}

	.testExamination_areafd1_1_c0_c0_c0_c1 {
		font-size: 26rpx;
		color: rgba(191, 191, 191, 1);
	}

	.testExamination_areafd1_1_c0_c0_c1 {
		background: rgba(242, 242, 242, 1);
		background-size: 100% !important;
		width: 602rpx;
		height: 16rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		background-size: 100% auto !important;
	}

	.testExamination_progress1_areafd1_1_c0_c0_c1 {
		background: rgba(21, 147, 255, 1);
		background-size: 100% !important;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
	}

	.testExamination_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.testExamination_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #111;
	}

	.testExamination_fd0_0_c1 {
		font-size: 32rpx;
		font-weight: bold;
		color: #111111;
	}

	.testExamination_fd0_0_c2 {
		width: 36rpx;
		height: 36rpx;
	}

	.testExamination_flex_0 {
		// border-bottom: 1px solid #eee;
		// background: #fff;
		background: url(https://speed.zhongchuxing.com/gjdimages/page_bg.png) no-repeat;
		background-size: 100% auto !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.page {
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://speed.zhongchuxing.com/gjdimages/page_bg.png) no-repeat #f6f7fb;
		background-size: 100% auto !important;
	}
</style>